<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  header("location:checklogin.php");
}

$dataFound = isset($_GET['dataFound']) ? $_GET['dataFound'] : 0;
if(isset($_REQUEST['go']))
{
  $lrNo = $_REQUEST['lrNo'];
  $select = "SELECT lrNo
               FROM loadinginvoicedetail
              WHERE lrNo = ".$lrNo;
  $res = mysql_query($select);
  $rows = mysql_num_rows($res);
  if($rows == "")
  {
    header("location:cashMemoNew.php");
  }
}
    


$i=0;
$unloadArray = array();
$selectunload = "SELECT  consignor,consignee,lorryFreight,octroi,octroiNo,lrNo
                        FROM loadinginvoicedetail
               ORDER BY consignor";
$selectunloadRes = mysql_query($selectunload);
while($unloadRow = mysql_fetch_array($selectunloadRes))
{
	$unloadArray[$i]['consignor']     = $unloadRow['consignor'];
	$unloadArray[$i]['consignee']     = $unloadRow['consignee'];
	$unloadArray[$i]['lorryFreight']  = $unloadRow['lorryFreight'];
	$unloadArray[$i]['octroi']        = $unloadRow['octroi'];
	$unloadArray[$i]['octroiNo']      = $unloadRow['octroiNo'];
	$unloadArray[$i]['lrNo']          = $unloadRow['lrNo'];
	$i++;
}

$truckDataArray = array();
$f = 0;
$selecttruck = "SELECT truckNo
                  FROM truckmaster
              ORDER BY truckNo";
$selecttruckResult = mysql_query($selecttruck);
while($truckdRow = mysql_fetch_array($selecttruckResult))
{
	$truckDataArray['truckNo'][$f] = $truckdRow['truckNo'];
	$f++;
}

$revicedArrayValue[0]  = "Yes";
$revicedArrayOutput[0] = "Yes";
$revicedArrayValue[1]  = "No";
$revicedArrayOutput[1] = "No";

//Branch Display
$k=0;  
$branchArray = array();
$selectBranch = "SELECT branchId,branchName
                   FROM branch";
$selectBranchRes = mysql_query($selectBranch);
while($branchRow = mysql_fetch_array($selectBranchRes))
{
	$branchArray['branchId'][$k]   = $branchRow['branchId'];
	$branchArray['branchName'][$k] = $branchRow['branchName'];
	$k++;
}
/////////invoce selcetion : Start
$m=0;
$loadArray = array();
$selectBranch = "SELECT loadingInvoiceId,invoiceNo
                   FROM loadinginvoice ";
$selectBranchRes = mysql_query($selectBranch);
while($branchRow = mysql_fetch_array($selectBranchRes))
{
	$loadArray['loadingInvoiceId'][$m]   = $branchRow['loadingInvoiceId'];
	$loadArray['invoiceNo'][$m]          = $branchRow['invoiceNo'];
	$m++;
}

include("./bottom.php");
$smarty->assign('dataFound',$dataFound);
$smarty->assign('truckDataArray',$truckDataArray);
$smarty->assign("unloadArray",$unloadArray);
$smarty->assign("revicedArrayOutput",$revicedArrayOutput);
$smarty->assign("revicedArrayValue",$revicedArrayValue);
$smarty->assign("branchArray",$branchArray);
$smarty->assign("loadArray",$loadArray);
$smarty->display('cashMemoNew.tpl');
?>